﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArbolandiaBL
{
    internal class ColorProvider
    {
        private ArbolandiaDBDataContext _db;

        public ColorProvider()
        {
            _db = new ArbolandiaDBDataContext();
        }
        internal List<CatColor> GetColors()
        {
            var query = _db.CatColor.Select(w => w);
            return query.Count() > 0 ? query.ToList() : new List<CatColor>();
        }
        internal void DeleteColor(Int32 id)
        {
            var query = _db.CatColor.Where(w => w.Id == id);
            if (query.Count() > 0)
            {
                _db.CatColor.DeleteOnSubmit(query.First());
                _db.SubmitChanges();
            }
        }
        internal void InsertColor(CatColor cc)
        {
            _db.CatColor.InsertOnSubmit(cc);
            _db.SubmitChanges();
        }
    }
}
